﻿// ------------------------------------------------------------------------------------
//      Copyright (c) uhavemyword@gmail.com. All rights reserved.
//      Created by Ben at 2/19/2013 10:38:43 PM
// ------------------------------------------------------------------------------------

namespace CP.NLayer.Service.Services.Test
{
    using System;
    using CP.NLayer.Client.Proxies;
    using CP.NLayer.Service.Contracts;
    using CP.NLayer.Service.Services;
    using Microsoft.Practices.Unity;

    public class DependencyInjection
    {
        private static readonly Lazy<IUnityContainer> _container = new Lazy<IUnityContainer>(() => new UnityContainer());

        static DependencyInjection()
        {
            ConfigureContainer(Container);
        }

        public static IUnityContainer Container
        {
            get { return _container.Value; }
        }

        public static void ConfigureContainer(IUnityContainer container)
        {
            bool isWcfService = false;
            if (isWcfService)
            {
                container.RegisterType<IRoleService, RoleServiceProxy>(new InjectionConstructor("RoleServiceEndPoint"));
                container.RegisterType<IUserService, UserServiceProxy>(new InjectionConstructor("UserServiceEndPoint"));
            }
            else
            {
                container.RegisterType<IRoleService, RoleService>(new InjectionConstructor());
                container.RegisterType<IUserService, UserService>(new InjectionConstructor());
            }
        }
    }
}
